package com.loong.ems.controller;

import com.loong.ems.domain.vo.resp.Result;
import com.loong.ems.service.SysDictService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 龙勇-229970722
 * @date 2025-01-03 8:38
 * @description: 字典数据获取，传入类别，查询字典数据，返回json数据，便于前端下拉框使用
 */

@RestController
@RequestMapping("/dict")
@Log4j2
@Tag(name = "字典管理", description = "字典数据或缺")
public class SysDictController {

    @Autowired
    private SysDictService sysDictService;

    /**
     * 获取字典数据
     * @param dictType
     * @return
     */
    @Operation(summary = "获取字典数据", description = "根据字典类别获取字典数据")
    @GetMapping("/getData/{dictType}")
    public Result<List<String>> getData(@PathVariable(value = "dictType") String dictType) {
        return Result.success(sysDictService.getDictData(dictType));
    }


}
